package com.sinodata.bsm.center.service.event;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.sinodata.bsm.center.bean.EventPropHisBean;
import com.sinodata.bsm.center.cache.PropertyValueCache;
import com.sinodata.bsm.center.dao.impl.EventPropHisDaoImpl;
import com.sinodata.bsm.common.vo.EventPropHis;

/**
 * <p>
 * Description: 事件指标历史值服务类
 * </p>
 *
 * @author dongyushi
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2012-6-4 PM 10:08:57     dongyushi      1.0         To create
 * </p>
 *
 * @since 
 * @see     
 */
@Service
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public class EventPropHisService {

    @Autowired
    private EventPropHisDaoImpl eventPropHisDao;

    @Autowired
    private PropertyValueCache propertyValueCache;

    /**
     * 根据事件ID获取事件发生时指标值(历史值)
     * 
     * @param eventId
     * @return
     */
    public List<EventPropHisBean> getEventPropHisByEventId(Long eventId) {
        return eventPropHisDao.getEventPropHisByEventId(eventId);
    }

    /**
     * 根据事件指标历史值对象获取当前指标值
     * 
     * @param eventPropHis
     * @return
     */
    public String getCurrentPropValue(EventPropHis eventPropHis) {
        Long resId = eventPropHis.getResId();
        Long propId = eventPropHis.getPropId();
        return propertyValueCache.getValue(resId, propId);
    }

}